package 输出和输入.zuoye;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class zuoye3 {
    public static void main(String[] args) {
        List<zuoye3t>list=new ArrayList<>();
        zuoye3t t=new zuoye3t();
        t.setAge(19);
        t.setName("张三");
        t.setXingbie("男");
        zuoye3t t1=new zuoye3t();
        t1.setAge(20);
        t1.setName("李四");
        t1.setXingbie("女");
        list.add(t);
        list.add(t1);
        FileOutputStream fos=null;
        ObjectOutput oos=null;
        try {
            fos=new FileOutputStream("F:word.txt");
            oos=new ObjectOutputStream(fos);
            oos.writeObject(list);
            oos.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (oos!=null){
                try {
                    oos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
